package com.cxh.rmsq.net.self

import com.aleyn.mvvm.base.BaseModel
import com.cxh.rmsq.db.model.AddressBean
import com.cxh.rmsq.db.model.AuthenticationBean
import com.cxh.rmsq.db.model.MineBean
import okhttp3.MultipartBody
import java.util.*


/**
 *   @auther : Aleyn
 *   time   : 2019/10/29
 */
class Repository private constructor(
    private val netWork: NetWork,
) : BaseModel() {

    suspend fun getSendSmsCode(mapOf: HashMap<String, Any>): BaseResult<Any> {
        return netWork.getSendSmsCode(mapOf)
    }

//    suspend fun getSmsLogin(mapOf: HashMap<String, Any>): BaseResult<LoginBean?> {
//        return netWork.getSmsLogin(mapOf)
//    }
//
//    suspend fun getLogin(mapOf: HashMap<String, Any>): BaseResult<LoginBean?> {
//        return netWork.getLogin(mapOf)
//    }

    suspend fun getLogout(mapOf: HashMap<String, Any>): BaseResult<Any?> {
        return netWork.getLogout(mapOf)
    }

    suspend fun setAuthentication(mapOf: HashMap<String, Any>): BaseResult<Any?> {
        return netWork.setAuthentication(mapOf)
    }

    suspend fun getAuthentication(userId: Int): BaseResult<AuthenticationBean?> {
        return netWork.getAuthentication(userId)
    }

    suspend fun getUserUpdate(mapOf: HashMap<String, Any>): BaseResult<Any?> {
        return netWork.getUserUpdate(mapOf)
    }

    suspend fun getProvinceList(): BaseResult<ArrayList<AddressBean>> {
        return netWork.getProvinceList()
    }

    suspend fun getCityList(code: String): BaseResult<ArrayList<AddressBean>> {
        return netWork.getCityList(code)
    }

    suspend fun getAreaList(code: String): BaseResult<ArrayList<AddressBean>> {
        return netWork.getAreaList(code)
    }

    suspend fun getUserInfo(userId: String): BaseResult<MineBean?> {
        return netWork.getUserInfo(userId)
    }

    suspend fun getFileUpdate(img: MultipartBody.Part): BaseResult<String?> {
        return netWork.getFileUpdate(img)
    }

    suspend fun changePwd(mapOf: HashMap<String, Any>): BaseResult<Any?> {
        return netWork.changePwd(mapOf)
    }

   suspend fun changePhone(mapOf: HashMap<String, Any>): BaseResult<Any?> {
        return netWork.changePhone(mapOf)
    }


    /**
     * ---------------------------------------------------------------------------------------------------------------------
     * 融云接口
     */
//    suspend fun getRCRegister(mapOf: HashMap<String, Any>): RCBaseResult<RCRegisterBean> {
//        return netWork.getRCRegister(mapOf)
//    }
//
//    suspend fun getFindUser(mapOf: HashMap<String, Any>): RCBaseResult<RCFindUserBean> {
//        return netWork.getFindUser(mapOf)
//    }
//
//
//    suspend fun getFriendAlls(): RCBaseResult<ArrayList<FriendShipInfo>> {
//        return netWork.getFriendAlls()
//    }
//
//    suspend fun getFindUserList( phone: String, region: String): RCBaseResult<RCFindUserBean> {
//        return netWork.getFindUserList(phone,region)
//    }

    companion object {

        @Volatile
        private var INSTANCE: Repository? = null

        fun getInstance(netWork: NetWork) =
            INSTANCE ?: synchronized(this) {
                INSTANCE ?: Repository(netWork).also { INSTANCE = it }
            }
    }
}